from django.contrib import admin

from .models import Question,Choice


class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3


class QuestionAdmin(admin.ModelAdmin):

    list_display = ('question_text', 'pub_date',
                    'was_published_recently','id')

    list_filter = ['pub_date']

    search_fields = ['question_text']

    list_per_page = 3

    fieldsets = [
        ('投票内容',               {'fields': ['question_text']}),
        ('时间', {'fields': ['pub_date']}),
    ]
    inlines = [ChoiceInline]


admin.site.register(Choice)
admin.site.register(Question, QuestionAdmin)